package com.macro.mall.demo.el;

import org.springframework.expression.Expression;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.expression.spel.support.StandardEvaluationContext;

public class ELDemo {
    public static void main(String[] args) {
        // EL 方法表达式解析
        ExpressionParser parser = new SpelExpressionParser();
        StandardEvaluationContext context = new StandardEvaluationContext();
        CustomerELRoot customerELRoot = new CustomerELRoot();
        customerELRoot.setName("zhangsan");
        context.setRootObject(customerELRoot);
        Expression expression = parser.parseExpression("nameMatch('zhang')");
        Boolean value = expression.getValue(context, Boolean.class);
        System.out.println("value = " + value);
    }

}
